import 'package:flutter/material.dart';

import 'package:get/get.dart';

import 'login_controller.dart';
import 'widgets/flare_teddy_widget.dart';
import 'widgets/form_widget.dart';

class LoginView extends GetView<LoginController> {
  void login() async {
    final result = await controller.login();
    if (result) {
      Get.offAllNamed('/home');
    } else {
      Get.snackbar('Error', 'login incorrect');
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Theme(
        data: Theme.of(context).copyWith(
          primaryColor: Colors.black54,
        ),
        child: Container(
          // width: double.infinity,
          // height: double.infinity,
          child: Stack(
            children: <Widget>[
              Positioned.fill(
                child: buildBackgroundWidget(),
              ),
              Positioned.fill(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    FlareTeddyWidget(),
                    FormWidget(),
                  ],
                ),
              )
            ],
          ),
        ),
      ),
    );
  }

  Container buildBackgroundWidget() {
    return Container(
      decoration: BoxDecoration(
        gradient: LinearGradient(
          begin: Alignment.topRight,
          end: Alignment.bottomLeft,
          stops: [
            0.0,
            1.0,
          ],
          colors: [
            Color.fromRGBO(255, 193, 7, .6),
            Color.fromRGBO(255, 235, 59, .6),
          ],
        ),
      ),
    );
  }

  /* End */
}
